<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>switch选择结构</title>
</head>

<body>
    <script>

        // 输入今天的周几
        // 1 3 5 超市面包打8折，2 4 6 超市薯片买1送1。7 全场商品打5折

        var days = parseInt(prompt('请输入今天周几：'))
        if (days === 1 || days === 3 || days === 5) {
            console.log('超市面包打8折');
        } else if (days === 2 || days === 4 || days === 6) {
            console.log('超市薯片买一送一');
        } else {
            console.log('全场商品打5折');
        }
        console.log('-------------------');
        // case不写break，会继续往后走的特点
        switch (days) {
            case 1:
            case 3:
            case 5:
                console.log('超市面包打8折');
                break;
            case 2:
            case 4:
            case 6:
                console.log('超市薯片买一送一');
                break;

            default: console.log('全场商品打5折');
                break; // default语句，如果写在最下面，break可以省略。
        }
    </script>
</body>

</html>